Skip to content

fix: update ZIP EOCD comment_length when signing#204

Open
bryan-anthropic wants to merge 1 commit intomainfrom
fix/eocd-comment-length
Open

fix: update ZIP EOCD comment_length when signing#204
bryan-anthropic wants to merge 1 commit intomainfrom
fix/eocd-comment-length

Conversation

@bryan-anthropic
Copy link
Collaborator

Summary

Fixes #194.

  • The signing function appends a signature block to the MCPB (ZIP) file without updating the EOCD comment_length field, causing strict ZIP parsers (including Claude Desktop's) to reject signed files.
  • Added findEocdOffset() helper to locate the EOCD record by scanning backwards for magic bytes 0x06054b50.
  • Before appending the signature block, the EOCD comment_length is now updated to include the signature block size.

Test plan

  • New test validates EOCD comment_length is correctly updated after signing
  • All existing signing tests continue to pass (110 total)
  • yarn build:code compiles cleanly
  • yarn lint passes

🤖 Generated with Claude Code

The signMcpbFile function appended a signature block to the ZIP file but
did not update the EOCD comment_length field. Strict ZIP parsers (like
Claude Desktop's) rejected these files because the declared comment
length didn't account for the appended signature data.

Now scans backwards for the EOCD magic bytes, reads the current
comment_length, and adds the signature block length before concatenating.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Collaborator Author

@bryan-anthropic bryan-anthropic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Claude Code

Clean, focused bug fix. Observations:

  • findEocdOffset() correctly scans backwards from buffer.length - 22 for the EOCD magic bytes (0x06054b50). The search range and byte-order handling look correct.
  • When EOCD is not found (offset === -1), the code silently skips the comment_length update. This preserves backward compatibility — the file was already a valid ZIP before signing, so failing to update this field is a safe fallback rather than a hard error.
  • The comment_length field at EOCD+20 is correctly written as a 16-bit little-endian value reflecting the size of the appended signature block.
  • Test coverage verifies both the before state (comment_length=0) and after state (comment_length equals appended data size), which are the two key assertions for this fix.
  • The test reimplements EOCD-finding logic rather than importing from sign.ts — reasonable since the function is private and the test needs independent verification.

No issues found. This should resolve the strict ZIP parser rejections observed in Claude Desktop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Report: Claude Desktop 1.1.3647 (8f7c53) 2026-02-19T15:02:19.000Z can't install signed extensions

1 participant